class User < ActiveRecord::Base
	before_save {self.email=email.downcase}
	validates :name, presence: true, length: { maximum: 50 }
	VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
	validates :email, presence:   true, 
					  format:     { with: VALID_EMAIL_REGEX },
	                  uniqueness: {case_sensitive:false}#uniqueness验证唯一性，case_sensitive设置区分大小写，false不区分
	has_secure_password
	validates :password,length:{minimum:6}     
end
